﻿using System;
using System.Web.UI.WebControls;
using Ue.Infrastructure.DomainBase;
using Ue.Infrastructure.Web.UI;
using Ue.Qcdz.Domain;
using Ue.Qcdz.Domain.Membership;

namespace Ue.Qcdz.UI.Controls
{
    public class UserList : SkinnedGridView
    {
        public UserList()
        {
            this.SearchKey = SiteContext.GetSiteContext().SearchKey;
            this.State = SiteContext.GetSiteContext().State;
        }


        private string skinFileName = "~/Admin/Themes/Skins/Membership/UserList.ascx";

        public string SearchKey { get; set; }
        public string State { get; set; }
        protected override string GetSkinFileName()
        {
            return skinFileName;
        }
        
        protected override void InitializeSkin(System.Web.UI.Control skin)
        {
            base.InitializeSkin(skin);

        }

        protected override void GridViewDataBind(object sender, EventArgs args)
        {
            IUserRepository userRepository= Ue.Infrastructure.RepositoryFramework.RepositoryFactory.GetRepository<IUserRepository, User>();

            IDataResult<User> dataResult = userRepository.FindBy(this);
            Repeater repeater = sender as Repeater;
            repeater.DataSource = dataResult.DataObjects;
            repeater.DataBind();
            this.RecordCount = dataResult.RecordCount;
        }

    }
}
